# channelid
id=$1
# 现在的apk包名
nowPackName=com.haogame.yeah
# 替换后apk包名
# toPackName=${nowPackName}${id};
toPackName=${nowPackName}

nowPackPath=${nowPackName//.//}
toPackPath=${toPackName//.//}
echo "nowPackPath="${nowPackPath}
echo "toPackPath="${toPackPath}

#apk的名称
apkFullName=default.apk
apkNameLen=${#apkFullName}
apkName=${apkFullName:0:$apkNameLen-4}
echo $apkName

# 修改channel.json版本号
newApkName=ClientP-${id}.apk
newApkFoler=ClientP-${id}
rm -r ${apkName}

# 反编译apk
# java -jar apktool.jar d ${apkName}.apk
java -jar apktool_2.6.0.jar -r d vivo_1.8.apk -o ${apkName}  -only-main-classes


# java -jar apktool.jar -r d ${apkName}.apk -o ${apkName}  -only-main-classes
echo "反编译apk finish"
echo "fixchannel"

# 替换androidmanifest.xml
# node fixpack.js $apkName $nowPackName $toPackName
# node fixappname.js $appname 
node fixchannel.js  ${apkName}/assets/channel.js ${id}

echo "apkName="${apkName}
java -jar apktool.jar b ${apkName}
# echo "重新打包apk finish"
mv ${apkName}/dist/${apkName}.apk output/$newApkName
echo "重命名apk"

jarsigner -verbose -storepass 666666 -keypass 666666 -sigalg SHA1withRSA -digestalg SHA1 -keystore ./jhao.keystore output/$newApkName jhao
echo "hao签名finish"









